#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>

int g_val = 10;
int main()
{
  printf("开始-扬帆起航！\n");
  pid_t pid =fork();//创建子进程

  if(pid == 0) {
    //子进程进入
    sleep(5);
    g_val=100;
    printf("this is child %d\n",g_val);
    exit(0);//退出程序的运行，子进程运行到这里就退出
  }
  else if(pid > 0) {
    printf("this is parents! %d\n",g_val);
  }
  else{
    //创建子进程出错
  }

  printf("游戏结束!\n");
  while(1) sleep(1);//死循环
  return 0;
}
